<!-- BEGIN: MON -->
<div class="list_hs">
    <table class="table table-striped">
        <tr>
            <td>ID</td>
            <td>Name</td>
            <td>diem 15ph</td>
            <td>diem 1 tiet</td>
            <td>diem hoc ky</td>
            <td>diem trung binh mon</td>
        </tr>
        <!-- BEGIN: HOCSINH -->
            <tr>
                <td><input type="hidden" value="{HOCSINH.id}" class="idhs"/>{HOCSINH.id}</td>
                <td>{HOCSINH.fullname}</td>
                <td class="ajaxedit key_15ph"><span>{HOCSINH.diemtp_15ph}</span></td>
                <td class="ajaxedit key_1t"><span>{HOCSINH.diemtp_1t}</span></td>
                <td class="ajaxedit key_hk"><span>{HOCSINH.diemtp_hk}</span></td>
                <td class="ajaxedit key_tbm"><span>{HOCSINH.diem_tbm}</span></td>
            </tr>
        <!-- END: HOCSINH -->
    </table>
    <input type="hidden" value="{idmon}" class="idmon" />
</div>
<script>
        $('.ajaxedit span').click(function(){
           var key = $(this).parent().attr('class').split(' ')[1];
           // alert($(this).text());
           var text = $(this).text();
            $(this).parent().append('<input class="dataedit" onblur="editdata($(this))" name="dataedit" value="'+text+'">');
            
            $(this).hide();
        });
        function editdata(id){
            var val =id.val();
            var key =id.parent().attr('class').split(' ')[1].toString();
            var idhs = id.parent().parent().find('.idhs').val();
             $.ajax({
                type:"POST",
                data:"diem="+val+"&idmon="+$('.idmon').val()+"&idhs="+idhs+"&key="+key,
                dataType: "json",
                url:"index.php?m=monhoc&act=editdiem",
                success:function(dt){
                    console.log(dt);
                    id.parent().text(dt);
                    $('.dataedit').hide();
                    id.parent().find('span').show();
                }
            });
        }
        
</script>
<!-- END: MON -->